package org.eenie.kdassistant.net.yd_api;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunda.crypt.EDOutputData;
import com.yunda.crypt.NativeEncryption;

import org.eenie.kdassistant.utils.LogUtil;

/**
 * Created by Eenie on 2017/8/28.
 * Email: eeniework@gmail.com
 * Des:
 */

public class YDBaseResponse {
    private Boolean success;
    private Long req_time;
    private String body;
    private String errorcode;

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Long getReq_time() {
        return req_time;
    }

    public void setReq_time(Long req_time) {
        this.req_time = req_time;
    }

    public String getBody() {

        return body;
    }



    public String getDecodeBody() {
        EDOutputData edData = new EDOutputData();

        String res = getBody();




        NativeEncryption.JNI_IDecrypt(res, edData);
        LogUtil.e(res + "\n" + edData.GetData());
        return edData.GetData();
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getErrorcode() {
        return errorcode;
    }

    public void setErrorcode(String errorcode) {
        this.errorcode = errorcode;
    }

    public JSONObject getEntity() {
        return JSON.parseObject(getBody());
    }


    public Object getEntity(Class clz) {

        LogUtil.json(getBody());



        return JSON.parseObject(getBody(), clz);
    }
    public Object  getDeEntity(Class clz) {

        return JSON.parseObject(getDecodeBody(), clz);
    }
    public JSONObject  getDeEntity() {
        return JSON.parseObject(getDecodeBody());
    }
}
